function p=onesided_ranksum(x,y)


%%%%%
% This function performs a one-sided rank sum test with the alternate
% hypothesis that the median of y is greater than that of x.
%
% Inputs:
% x - 1D vector containing data from the first group.
% y - 1D vector containing data from the second group. x and y do not have to have the same length.
%
% Output:
% p - p-vaule of the one-sided ranksum test.
%
% Written by Joon Lee, 2011
%%%%%


[p,h,stats]=ranksum(x,y);

if stats.zval<0     % this means x<y
    p=p/2;
else
    p=1-p/2;
end
